#include "mod-icmp4.hpp"

Record * Icmp4Decoder::decode (Packet & pkt, Record & prev)
{
  Icmp4Record &r = this->rec;
  Icmp4Hdr * hdr = (Icmp4Hdr*) pkt.getCur ();
  const int hdrLen = sizeof (Icmp4Hdr);
  
  debug (DEBUG, "Etner ICMP4 decoder");
  if (NULL == hdr || ! pkt.moveCur (hdrLen) || ! r.lock ())
    return NULL;

  r.setData (DEC_ICMP4, hdr, hdrLen);

  debug (DEBUG, "Leave ICMP4 decoder");
  return &(this->rec);
}


NDecFilter * Icmp4Decoder::makeFilter (string &name)
{
  Icmp4Filter * f = NULL;

  if (name == "icmp.type")
    f = new Icmp4Filter (Icmp4Filter::FT_TYPE);
  else if (name == "icmp.code")
    f = new Icmp4Filter (Icmp4Filter::FT_CODE);

  return f;
}


//==========================================================


bool Icmp4Filter::setup (string &arg)
{
  // to be implemented
  return false;
}

void Icmp4Filter::check (NDecResult &res)
{
  // to be implemented
  return ;
}


